﻿#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Cookies;
use HTTP::Request::Common;

$myCookies = HTTP::Cookies->new(
    file     => "cookies.txt",
    autosave => 1,
    );

$URL  = "http://www.example.com/login.php";
$UA   = LWP::UserAgent->new();
$UA->cookie_jar( $myCookies );

$req  = HTTP::Request->new( GET => "http://www.example.com/" );
$resp = $UA->request($req);

# Kontrola błędów. Wyświetlenie strony, jeśli wszystko jest OK.
if ( ( $resp->code() >= 200 ) && ( $resp->code() < 400 ) ) {
    print $resp->decoded_content;
} else {
    print "Błąd: " . $resp->status_line . "\n";
}
